GBML manual / Backgrounds

background_clip

Shows only a box of bg: its top-left corner is at (x, y), counted from the top-left like draw_background, and it is w wide and h tall. Nothing of the background shows outside the box.

Works differently on Game Boy - The Game Boy hides everything outside the box with black blocks of 8 by 8 pixels, so the box's edges snap to that grid, and the box starts one frame after the call. It ends with the room or the background.

Works differently on Game Boy Color - The Game Boy Color hides everything outside the box with black blocks of 8 by 8 pixels, so the box's edges snap to that grid, and the box starts one frame after the call. It ends with the room or the background.

Sega Genesis: not built yet

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

background_clip(bg, x, y, w, h)

Arguments

NameType
bgbackground
xreal
yreal
wreal
hreal

Returns

Nothing.

Description

Shows only a box of bg: nothing of the background shows outside it. A no-op on nothing.

(x, y) is the box's top-left corner, and w and h are its width and height. They use the same numbers as draw_background: places in the room, counted from the room's top-left corner, when a Draw event draws the background; the screen's own pixels, counted from its top-left pixel, when a Draw GUI event does. The box stays where you put it while the background moves, like a window in a wall. A box with no width or height shows nothing.

The box takes effect the next time the background is drawn and stays until background_clip_off takes it off.

A clip uses one of the console's two rectangle windows. A transition that cuts a shape and an overlay effect with a shape use these windows too. If both are taken, the background is drawn without the clip. The Budgets panel's Windows row counts how many your room's backgrounds can hold. In a dark (shrouded) room the darkness is not drawn inside the box, because the console lets a rectangle window win over the lights.

Example

backdrop = background_create(0, 0, ts_doc_dungeon);
background_clip(backdrop, 40, 30, 100, 60);

Makes a background from the dungeon picture and shows only a box of it, 100 pixels wide and 60 tall, whose top-left corner is 40 pixels right of and 30 pixels below the room's top-left corner.

On the GBA

A no-op on `nothing`. The box uses the same numbers draw_background does: places in the room when a Draw event draws the background, and the screen’s own pixels when a Draw GUI event does. It stays put in the room (or on the screen) while the background moves, like a window in a wall. It takes effect the next time the background is drawn and stays until background_clip_off. A box of no width or height shows nothing. The clip takes one of the console’s two rectangle windows, shared with screen transitions that cut shapes and with overlay effects that have a shape: if both are taken, the background is drawn without the clip and the development log says so in plain words. In a dark (shrouded) room the darkness is not drawn inside a clipped box, because the console lets a rectangle window win over the lights.

See also: background_clip_offbackground_repeatbackground_edgedraw_backgroundBackgrounds